<?php
$this->headTitle($this->translator('message_inbox'));
?>

<style>
    .caption{
		font-weight: bold;
		background: #BCBBB9;
	}
	
	.box_account .grid_3{
		width: 250px;
		margin: 0;		
	}
	
	.box_account .grid_3:hover{
		background: #EFEDED;
	}
	
	.box_account .grid_3 label{
        display:block;
        float:left;
        height:26px;
        line-height:15px;
        margin-right:10px;
        width:80px;
    }  
    
    table{
		border-top:none;
		border-bottom:none;
	}
	.list table{
		width: 100%;
		border-top: 0px;
		border-bottom: 0px;
	}
	.list .caption td{
		font-weight: bold;
		background: #BCBBB9;
	}
	.list tr.caption:hover td{
		font-weight: bold;
		background: #BCBBB9;
	}
	.list tbody tr:hover td{
		background: #EFEDED;
	} 
    
    .evaluation_label{
    	display: block; 
    	float: left; 
    	line-height: 15px;
    	margin-right: 20px;
		width: 80px; 
    }
</style>

<div class="grid_8_alpha ">
	<?php
		$arrParamMessage = array(
			'enterprise_id' => $this->enterprise->id,
			'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true)
		);
	?>
	<ul class="tabNavigation">
		<li><a class="selected" href="<?php echo $this->url($arrParamMessage, 'bizprofile_message_inbox'); ?>"><?php echo $this->translator('message_breakcrumb_indox');?></a></li>
		<li><a href="<?php echo $this->url($arrParamMessage, 'bizprofile_message_send'); ?>"><?php echo $this->translator('message_breakcrumb_outbox');?></a></li>
	</ul> 
</div>
<?php if ($this->numMessage == 0) : ?>
<div class="grid_12 t_a_bottom">
    <?php echo $this->translator('message_box_not_found'); ?>
</div>
<?php else : ?>
<div class="grid_12 t_a_bottom">
    <table cellpadding="0" cellspacing="0"  class="list">
    <tr class="caption">
    	<td width="150px"><?php echo $this->translator('message_caption_from');?></td>
        <td width="350px"><?php echo $this->translator('message_caption_title');?></td>
        <td width="50px" style="text-align:center;"><?php echo $this->translator('message_caption_date');?></td>
        <td width="50px" style="text-align:center;"><?php echo $this->translator('message_caption_action');?></td>
    </tr>
    <?php foreach ($this->message as $row) : ?>
		<?php
		    $arrParamView = array(
		        'enterprise_id' => $this->enterprise->id,
		        'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true),
		        'message_id' => $row->id
		    );
		
		    if(isset($this->arrEnt[$row->id])) // Nguoi gui la Enterprise
		    {
		        /**
		         * Enterprise follow message to view
		        **/
		        $arrEnt = $this->arrEnt[$row->id];
		        $arrRouteEnterprise = array(
		            'enterprise_id' => $arrEnt['e_id'],
		            'enterprise_name' => Tomato_Utility_String::removeSign($arrEnt['e_name'], '-', true)
		        );
		        $arrRouteEnterpriseRemove = array(
		            'enterprise_id'   => $this->enterprise->id,
		            'enterprise_name' => Tomato_Utility_String::removeSign($arrEnt['e_name'], '-', true),
					'message_id'	  => $row->id		
		        );	
		    	        		
		?>
        <tr>
            <td>
                <a href="<?php  echo $this->url($arrRouteEnterprise, 'bizprofile_enterprise_index'); ?>"><?php echo $row->fromenterprise_name; ?></a>
            </td>
            <td><a class="<?php if($row->messageread == 1): ?>read<?php else: ?>unread<?php endif; ?>" href="<?php echo $this->url($arrParamView, 'bizprofile_message_view'); ?>"><?php echo $row->title;?></a><br></td>
            <td><?php echo date('d/m/Y', $row->dateline_send);?></td>
            <td style="text-align:center;">
				<a href="<?php  echo $this->url($arrRouteEnterpriseRemove, 'bizprofile_message_delete'); ?>" onclick="return confirm('<?php echo $this->translator('message_delete_confirm');?>');">
					<?php echo $this->translator('message_action_delete');?>
				</a>
			</td>
        </tr>
        <?php
		    }
		    else // Nguoi gui la User
		    {
		    	$arrRouteEnterpriseRemove = array(
		            'enterprise_id'   => $this->enterprise->id,
		            'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true),
					'message_id'	  => $row->id		
		        );	
		?>
		<tr>
            <td>
                <?php echo $row->fromuser_name; ?>
            </td>
            <td><a class="<?php if($row->messageread == 1): ?>read<?php else: ?>unread<?php endif; ?>" href="<?php echo $this->url($arrParamView, 'bizprofile_message_view'); ?>"><?php echo $row->title;?></a><br></td>
            <td><?php echo date('d/m/Y', $row->dateline_send);?></td>
            <td style="text-align:center;">
				<a href="<?php  echo $this->url($arrRouteEnterpriseRemove, 'bizprofile_message_delete'); ?>" onclick="return confirm('<?php echo $this->translator('message_delete_confirm');?>');">
					<?php echo $this->translator('message_action_delete');?>
				</a>
			</td>
        </tr>
		<?php    	
		    }
        ?>
    <?php endforeach; ?>
    </table>
</div>
<div class="grid_12 t_a_bottom t_a_paginator">
    <?php echo $this->paginator()->slide($this->paginator, $this->paginatorOptions);?>
</div>
<?php endif; ?>
